<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // function asyncOperation() {
      //   return new Promise((resolve, reject) => {
      //     setTimeout(() => {
      //       const result = "Data loaded";
      //       resolve(result);
      //     }, 2000);
      //   });
      // }

      // asyncOperation()
      //   .then((data) => {
      //     console.log(data);
      //   })
      //   .catch((error) => {
      //     console.error(error);
      //   });
      let myFirstPromise = new Promise((resolve, reject) => {
        let aaa=undefined
        // 执行一些异步操作...
        if (aaa) {
          resolve("Success!"); // 成功时调用resolve
        } else {
          reject("Error!"); // 失败时调用reject
        }
      });
      myFirstPromise
        .then((response,reject) => console.log(response,reject))
        .catch((error) => console.log(error))
        .finally(() => console.log("This will run no matter what."));
    </script>
  </body>
</html>
